using System;
using Controls;
using Events;
using UI;
using UnityEngine;

namespace Globals.States
{
    public class GameOverState : MonoBehaviour, IState
    {
        [SerializeField] private VoidEventChannel gameOverEvent;
        [SerializeField] private PlayerController playerController;

        [SerializeField] private GameObject pause;
        [SerializeField] private GameOverUi gameOverUi;


        private void Start()
        {
            gameOverEvent.Init();
        }

        public void Enter()
        {
            playerController.OnGameOver();
            Time.timeScale = 0f;

            pause.SetActive(false);
            gameOverUi.Show();
            
            gameOverEvent.Raise();
        }

        public void OnUpdate()
        {
        }

        public void Exit()
        {
            Time.timeScale = 1f;
        }
    }
}
